#pragma once
#include "UIControl.h"
#include"UILabel.h"

BEGIN_NAMESPACE(ui_manager)
BEGIN_NAMESPACE(ui_controls)

typedef void(*click_callback)(void);

class UIButton;
typedef std::shared_ptr<UIButton> UIButtonPtr; // Shared pointer to manage dynamic UIButton objects

class UIButton : public UIControl
{
	friend class UIManager;

	UILabel text;
	int state_;
	bool enabled_;
	click_callback on_click_;
	ui_manager::ui_graphics::UIImage* click_img_;
	ui_manager::ui_graphics::UIImage* hover_img_;

	void Render(UIPoint parentPosistion);
	
protected:

public:
	UIButton(void);
	~UIButton(void);
	// Setters
	void SetOnClick(click_callback _callback){on_click_ = _callback;}
	void SetEnabled(bool enabled){enabled_ = enabled;}
	void SetOnClickImage(ui_manager::ui_graphics::UIImage* img){click_img_ = img;}
	void SetOnHoverImage(ui_manager::ui_graphics::UIImage* img){hover_img_ = img;}

	//

	void setSize(UISize size);
	//void setPosition(UIPoint pos);

	// Getters
	click_callback GetOnClick() const{return on_click_;}
	bool IsEnabled() const{return enabled_;}
	const ui_manager::ui_graphics::UIImage& GetOnClickImage()const {return *click_img_;}
	const ui_manager::ui_graphics::UIImage& GetOnHoverImage()const {return *hover_img_;}
	UILabel& GetLabel(){return text;}

	void HandleEvent(ui_events::UIEvent ui_event);
	void BoundBy(UIManager& manager, bool is_component);
};

END_NAMESPACE // ui controls
END_NAMESPACE // ui manager